from sanic import Sanic, response
import json

from my_redis.redis_1 import sanic_bp
from view.register import bp1
from my_crypto.pcrypto import *


# 蓝图
app = Sanic(__name__)
app.blueprint(bp1)
app.blueprint(sanic_bp)


@app.middleware('response')
async def add(request, response):
    response.headers["Access-Control-Allow-Origin"] = '*'
    response.headers["Access-Control-Allow-Methods"] = "POST,GET,OPTIONS"
    response.headers["Access-Control-Expose-Headers"] = "Set-Cookie,token"
    response.headers["Access-Control-Allow-Headsanic_demo/main/usr.py:16ers"] = "Set-Cookie,token"
    response.headers["Access-Control-Allow-Credentials"] = "true"


@app.route('/hello', methods=['GET', 'POST'])
async def test_hello(request):
    return response.text('hah')


if __name__ == '__main__':
    app.run(host='0.0.0.0', port='8000', debug=True)

